/* 多源汇最大流
* 1.问题描述
    建虚拟源汇点，让虚拟源点向所有源点连一条容量为+∞的边，所有汇点向虚拟汇点连一条容量为+∞的边。
    答案就是虚拟源点到虚拟汇点的最大流。
* 2.注
    反向边流量也可计入最大流，正向流的量回退即可，但仍不可超出这条边的容量
*/
#define DEBUG
#pragma GCC optimize("O1,O2,O3,Ofast")
#pragma GCC optimize("no-stack-protector,unroll-loops,fast-math,inline")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,ssse3")

#include <iostream>
#include <cstring>
using namespace std;
// #define int long long
const int N = 10010, M = (10200+N)*2, INF = 0x3f3f3f3f;

int n, m, S, T;
int h[N], e[M], ne[M], f[M],  idx; //f表示容量
int q[N], d[N], cur[N], A[N]; 
// d[i]: 分层图每个点的深度
// cur[i]：弧优化
// //A[i] 表示点i所有入边的容量下界之和 - 点i所有出边的容量下界之和

void AddEdge(int a, int b, int c)
{
    e[idx] = b, f[idx] = c, ne[idx] = h[a], h[a] = idx++;
    e[idx] = a, f[idx] = 0, ne[idx] = h[b], h[b] = idx++;
}

bool bfs()
{
    memset(d, -1, sizeof d);
    int hh = 0, tt = -1;
    q[++tt] = S, d[S] = 0, cur[S] = h[S];
    while(hh <= tt)
    {
        int u = q[hh++];
        for(int i = h[u]; ~i; i = ne[i])
        {
            int v = e[i];
            if(d[v] == -1 && f[i])
            {
                d[v] = d[u]+1;
                cur[v] = h[v];
                if(v == T) return true;
                q[++tt] = v;
            }
        }
    }
    return false;
}

int find(int u, int limit) //从 u 往终点传输尽可能多的流量，上限为 limit
{
    if(u == T) return limit;
    int flow = 0;
    for(int i = cur[u]; ~i && flow < limit; cur[u] = i, i = ne[i])
    {
        int v = e[i];
        if(d[v] == d[u]+1 && f[i])
        {
            int t = find(v, min(f[i], limit - flow));
            if(!t) d[v] = -1;
            f[i] -= t, f[i^1] += t, flow += t;
        }
    }
    return flow;
}

int Dinic()
{
    int r = 0, flow = 0;
    while(bfs())
        while(flow = find(S, INF)) r += flow;
    return r;
}


signed main()
{
    #ifdef DEBUG
        freopen("./in.txt", "r", stdin);
    #else
        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #endif

    int sc, tc;
    cin >> n >> m >> sc >> tc;
    memset(h, -1, sizeof h);

    S = 0, T = n+1; //虚拟源点
    while(sc--)
    {
        int s; cin >> s;
        AddEdge(S, s, INF);
    }

    while(tc--)
    {
        int t; cin >> t;
        AddEdge(t, T, INF);
    }

    while(m--)
    {
        int a, b, c; cin >> a >> b >> c;
        AddEdge(a, b, c);
    }

    printf("%d\n", Dinic());
    return 0;
}